package com.itheima.chapter11.tcp.case3;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Server {
    public static void main(String[] args) throws IOException {
        ThreadPoolExecutor pool =new ThreadPoolExecutor(2,5,60, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());
        ServerSocket server =new ServerSocket(9997);
        System.out.println("服务端开启，等待客户端链接...");
        while(true){
            //响应客户发送的请求
            Socket socket =server.accept();
           //new Thread(new submitFileTask(socket)).start();
            pool.submit(new submitFileTask(socket));
        }

    }
}
